package 线程安全.多线程.单线程;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;

public class Server {
    public static void main(String[] args) throws IOException {
        ServerSocket server = new ServerSocket(12306);
        Socket socket = server.accept();
        Scanner sc = new Scanner(System.in);
        while (true) {

            BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            String s = br.readLine();
            System.out.println("李捷:" + s);

            System.out.print("我: ");
            String str = sc.nextLine();
            BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
            bw.write(str + "\r\n");

            bw.flush();


//            socket.close();
        }


    }
}
